home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / Newton Platform Info / Newton 2.0 Sample Code / Digital Books / Beyond Help-5 / Help Book Source.f < prev    next >
Encoding:
Text File  |  1995-11-21  |  9.5 KB  |  430 lines  |  [TEXT/MPS ]

  1. // Created by Newton Book Maker 1.1
  2. // ¡¡ Note: This file may contain needed resources !! 
  3. // Document
  4. book := {
  5.     version: 2,
  6.     isbn: "ISBN5:12:20 PM",
  7.     help: TRUE,
  8.     contents: Array(24, NIL),
  9.     styles: [],
  10.     browsers: [], templates: [], rendering: []};
  11.  
  12. // The following two lines have been manually commented out...
  13. // see the BookMaker 1.1 release notes.  (This is a VERY
  14. // important thing to do to create help books!)
  15. // output.book := book;
  16. // output.help := TRUE;
  17.  
  18. // Shared Map Functions
  19. func MakePage(aTemplate)
  20.     {template: aTemplate, blocks: []};
  21. func MakeBlock(aBounds, anItem)
  22.     {bounds: aBounds, item: anItem};
  23.  
  24. // Shared Scripts
  25. gotoDestScript := func() begin
  26.     if (curRendering = 0) then :TurnToPage(destPage);
  27.     else :TurnToPage(:FindPageByContent(kioskDest, 0, NIL));
  28. end;
  29.  
  30. // Text Styles
  31. s0 := {
  32.     family: 'Geneva,
  33.     face: 0,
  34.     size: 9};
  35. AddArraySlot(book.styles, s0);
  36.  
  37. s1 := {
  38.     family: 'espy /* Monaco */,
  39.     face: 0,
  40.     size: 10};
  41. AddArraySlot(book.styles, s1);
  42.  
  43. s2 := {
  44.     family: 'Espy,
  45.     face: 1,
  46.     size: 10};
  47. AddArraySlot(book.styles, s2);
  48.  
  49. s3 := {
  50.     family: 'Espy,
  51.     face: 0,
  52.     size: 10};
  53. AddArraySlot(book.styles, s3);
  54.  
  55. s4 := {
  56.     family: 'Geneva,
  57.     face: 0,
  58.     size: 9};
  59. AddArraySlot(book.styles, s4);
  60.  
  61. s5 := {
  62.     family: 'Geneva,
  63.     face: 0,
  64.     size: 10};
  65. AddArraySlot(book.styles, s5);
  66.  
  67. s6 := {
  68.     family: 'espy /* Avant Garde */,
  69.     face: 0,
  70.     size: 10};
  71. AddArraySlot(book.styles, s6);
  72.  
  73.  
  74. // Contents
  75. c1 := {
  76.     data: "About Beyond Help",
  77.     viewFont: s2,
  78.     layout: 32
  79. };
  80. book.contents[0] := c1;
  81.  
  82. c2 := {
  83.     data: "
  84. This is a sample help book, written to demonstrate how to add help to your application.  The app has two buttons, both of which open the manual, but the 2nd opens the manual so that the Llamas topic is open.
  85.  
  86. Sample app and help book by Bob Ebert.
  87.  
  88. Many thanks to the Scott Shwarts and David Dunham for help creating this sample.",
  89.     viewFont: s3
  90. };
  91. book.contents[1] := c2;
  92.  
  93. c3 := {
  94.     data: "Help Book Overview",
  95.     viewFont: s2,
  96.     layout: 32
  97. };
  98. book.contents[2] := c3;
  99.  
  100. c4 := {
  101.     data: "
  102. The help book is organized into two main levels, a \"topics\" level and a \"page\" level.  The book always opens to the  topics level, and each line in the topics level can either have subtopics or a single page.
  103.  
  104. Each page is meant to describe a specific topic.  The content for a topic cannot be larger than a page, as no scrolling is supported.  The only navigation available from a page is to return to the topics.",
  105.     viewFont: s3
  106. };
  107. book.contents[3] := c4;
  108.  
  109. c5 := {
  110.     data: "Help Book Usage",
  111.     styles: [15, s2, 1, s3],
  112.     layout: 32
  113. };
  114. book.contents[4] := c5;
  115.  
  116. c6 := {
  117.     data: "
  118. Help books are intended to provide \"How Do I\" type help to an application.  It should list step by step instructions to get a user on the right track.
  119.  
  120. The main rule for help books is KISS:
  121.     Keep It Simple, Stupid
  122.  
  123. The help book should tells users what they need to know to perform some task with an application, and not much else.
  124. ",
  125.     styles: [185, s3, 4, s2, 145, s3],
  126.     tabs: [18]
  127. };
  128. book.contents[5] := c6;
  129.  
  130. c7 := {
  131.     data: "Things to avoid",
  132.     styles: [15, s2, 1, s3],
  133.     layout: 32
  134. };
  135. book.contents[6] := c7;
  136.  
  137. c8 := {
  138.     data: "
  139. Help books are not designed to present the entire users manual.  (You might consider using a separate electonic book for that.)
  140.  
  141. Application help books should not describe how to perform system-wide tasks, such as Faxing or Printing.  (The System Help Book already describes those.)  Only special tasks for your application need to be described.
  142.  
  143. This help book is a bad example.  :-)",
  144.     styles: [382, s3, 4, s4]
  145. };
  146. book.contents[7] := c8;
  147.  
  148. c9 := {
  149.     data: "Building a Help Book",
  150.     styles: [20, s2, 1, s3],
  151.     layout: 32
  152. };
  153. book.contents[8] := c9;
  154.  
  155. c10 := {
  156.     data: "
  157. •    Build your book in the word processor.
  158. •    Drop the file on Newton BookMaker
  159. •    Choose Help Size in the Options menu.
  160. •    Click on the \"Do It\" button.
  161. •    Save the result.
  162. •    Add code to Project Data to read in the book. e.g., 
  163.     ref := OpenResFileX(HOME&\"book.f\");
  164.     load(HOME&\"book.f\");
  165.     CloseResFileX(ref) ;
  166. •    The book is available to the app.",
  167.     styles: [61, s3, 16, s5, 10, s3, 9, s5, 8, s3, 7, s5, 199, s3, 4, s5, 26, s3],
  168.     tabs: [18]
  169. };
  170. book.contents[9] := c10;
  171.  
  172. c11 := {
  173.     data: "User Interface for Opening",
  174.     styles: [26, s2, 1, s3],
  175.     layout: 32
  176. };
  177. book.contents[10] := c11;
  178.  
  179. c12 := {
  180.     data: GetNamedResource("PICT", "16789", 'picture)
  181. };
  182. book.contents[11] := c12;
  183.  
  184. c13 := {
  185.     data: "
  186. The interface element you use for accessing help is the protoInfoButton, which is a system prototype included in Newton 2.0. 
  187.  
  188. There is a code sample 'infoButton' which includes a simple protoInfoButton proto, for use for pre-Newton 2.0 machines.  It will not do everything that the Newton 2.0 proto does, but it works.",
  189.     viewFont: s3
  190. };
  191. book.contents[12] := c13;
  192.  
  193. c14 := {
  194.     data: "Opening a Help Book",
  195.     styles: [19, s2, 1, s3],
  196.     layout: 32
  197. };
  198. book.contents[13] := c14;
  199.  
  200. c15 := {
  201.     data: "
  202. •    Create a template frame like this:
  203.     {_proto: GetRoot().TinyTim._proto,
  204.      bookRef: theBook}
  205. •    Build a view using BuildContext()
  206. •    Send the OpenManual message
  207.     to the view.
  208. •    Or use OpenManualTo().
  209.  
  210. •    Be sure to close the Help Book when
  211.     the app closes.",
  212.     styles: [38, s3, 56, s5, 21, s3, 14, s5, 54, s3, 14, s5, 58, s3],
  213.     tabs: [18]
  214. };
  215. book.contents[14] := c15;
  216.  
  217. c16 := {
  218.     data: "A Font Tip",
  219.     styles: [10, s2, 1, s3],
  220.     layout: 32
  221. };
  222. book.contents[15] := c16;
  223.  
  224. c17 := {
  225.     data: "
  226. You should consider using the system font (Espy Sans) for your help book.  A bitmap version Espy Sans comes with Newton ToolKit.
  227.  
  228. Or, just use any font besides New York or Geneva.  The Newton BookMaker turns all unknown fonts into Espy Sans.  (The source for this paragraph is in Avant Garde!)",
  229.     styles: [131, s3, 163, s6, 1, s3]
  230. };
  231. book.contents[16] := c17;
  232.  
  233. c18 := {
  234.     data: "Llamas (a topic with subtopics)",
  235.     layout: 2048
  236. };
  237. book.contents[17] := c18;
  238.  
  239. c19 := {
  240.     data: "Llama Basics",
  241.     viewFont: s2,
  242.     layout: 32, 
  243.     name: "LlamaTopic"
  244. };
  245. book.contents[18] := c19;
  246.  
  247. c20 := {
  248.     data: GetNamedResource("PICT", "22007", 'picture),
  249.     layout: 4
  250. };
  251. book.contents[19] := c20;
  252.  
  253. c21 := {
  254.     data: "    A llama is:
  255.         Helpful
  256.         Courteous
  257.         Kind
  258.         Obedient
  259.         Cheerful
  260.         Thrifty
  261.         Brave
  262.         Clean
  263.         Reverent",
  264.     viewFont: s3,
  265.     tabs: [36, 54]
  266. };
  267. book.contents[20] := c21;
  268.  
  269. c22 := {
  270.     data: "Llama don'ts",
  271.     viewFont: s2,
  272.     layout: 32
  273. };
  274. book.contents[21] := c22;
  275.  
  276. c23 := {
  277.     data: GetNamedResource("PICT", "31160", 'picture),
  278.     layout: 4
  279. };
  280. book.contents[22] := c23;
  281.  
  282. c24 := {
  283.     data: "NEVER:
  284. • Whack your llama.
  285. • Taunt your llama.
  286. • Mock your llama.
  287. • Leave your llama out in the rain.
  288. • Expose your llama to direct sunlight.
  289. • Let your llama run heavy machinery.
  290. • Mix your llama with alcohol or drugs.
  291. • Fold, Spindle, or Mutilate your llama.
  292. • Let your llama eat lupines.",
  293.     styles: [7, s2, 284, s3]
  294. };
  295. book.contents[23] := c24;
  296.  
  297.  
  298. // Kiosk (menu page) references
  299.  
  300. // Page Templates
  301. NBMDefault := {
  302.     nColumns: 1,
  303.     column: [{
  304.     width: 12,
  305.     type: 0}]
  306. };
  307. AddArraySlot(book.templates, NBMDefault);
  308.  
  309. // Bounds List
  310. bnd1 := [0,0,206,14];
  311. bnd2 := [0,14,206,214];
  312. bnd3 := [0,14,120,34];
  313. bnd4 := [0,34,206,214];
  314. bnd5 := [87,14,119,46];
  315. bnd6 := [0,46,206,214];
  316. bnd7 := [0,46,206,186];
  317.  
  318. // Pages
  319. pageList := {pageSize: {left: 0, top: 0, right: 206, bottom: 214}, pages: []};
  320.  
  321. // Page 1
  322. page := MakePage(NBMDefault);
  323. AddArraySlot(page.blocks, MakeBlock(bnd1, c1));
  324. AddArraySlot(page.blocks, MakeBlock(bnd2, c2));
  325. AddArraySlot(pageList.pages, page);
  326.  
  327. // Page 2
  328. page := MakePage(NBMDefault);
  329. AddArraySlot(page.blocks, MakeBlock(bnd1, c3));
  330. AddArraySlot(page.blocks, MakeBlock(bnd2, c4));
  331. AddArraySlot(pageList.pages, page);
  332.  
  333. // Page 3
  334. page := MakePage(NBMDefault);
  335. AddArraySlot(page.blocks, MakeBlock(bnd1, c5));
  336. AddArraySlot(page.blocks, MakeBlock(bnd2, c6));
  337. AddArraySlot(pageList.pages, page);
  338.  
  339. // Page 4
  340. page := MakePage(NBMDefault);
  341. AddArraySlot(page.blocks, MakeBlock(bnd1, c7));
  342. AddArraySlot(page.blocks, MakeBlock(bnd2, c8));
  343. AddArraySlot(pageList.pages, page);
  344.  
  345. // Page 5
  346. page := MakePage(NBMDefault);
  347. AddArraySlot(page.blocks, MakeBlock(bnd1, c9));
  348. AddArraySlot(page.blocks, MakeBlock(bnd2, c10));
  349. AddArraySlot(pageList.pages, page);
  350.  
  351. // Page 6
  352. page := MakePage(NBMDefault);
  353. AddArraySlot(page.blocks, MakeBlock(bnd1, c11));
  354. AddArraySlot(page.blocks, MakeBlock(bnd3, c12));
  355. AddArraySlot(page.blocks, MakeBlock(bnd4, c13));
  356. AddArraySlot(pageList.pages, page);
  357.  
  358. // Page 7
  359. page := MakePage(NBMDefault);
  360. AddArraySlot(page.blocks, MakeBlock(bnd1, c14));
  361. AddArraySlot(page.blocks, MakeBlock(bnd2, c15));
  362. AddArraySlot(pageList.pages, page);
  363.  
  364. // Page 8
  365. page := MakePage(NBMDefault);
  366. AddArraySlot(page.blocks, MakeBlock(bnd1, c16));
  367. AddArraySlot(page.blocks, MakeBlock(bnd2, c17));
  368. AddArraySlot(pageList.pages, page);
  369.  
  370. // Page 9
  371. page := MakePage(NBMDefault);
  372. AddArraySlot(page.blocks, MakeBlock(bnd1, c19));
  373. AddArraySlot(page.blocks, MakeBlock(bnd5, c20));
  374. AddArraySlot(page.blocks, MakeBlock(bnd6, c21));
  375. AddArraySlot(pageList.pages, page);
  376.  
  377. // Page 10
  378. page := MakePage(NBMDefault);
  379. AddArraySlot(page.blocks, MakeBlock(bnd1, c22));
  380. AddArraySlot(page.blocks, MakeBlock(bnd5, c23));
  381. AddArraySlot(page.blocks, MakeBlock(bnd7, c24));
  382. AddArraySlot(pageList.pages, page);
  383.  
  384. AddArraySlot(book.rendering, pageList);
  385.  
  386. // Browsers & “Page Hints”
  387. b1 := {
  388.     name: "Contents",  list: []
  389. };
  390.  
  391.  
  392. AddArraySlot(b1.list, {    // 0
  393.     item: c1
  394. });
  395. AddArraySlot(b1.list, {    // 1
  396.     item: c3
  397. });
  398. AddArraySlot(b1.list, {    // 2
  399.     item: c5
  400. });
  401. AddArraySlot(b1.list, {    // 3
  402.     item: c7
  403. });
  404. AddArraySlot(b1.list, {    // 4
  405.     item: c9
  406. });
  407. AddArraySlot(b1.list, {    // 5
  408.     item: c11
  409. });
  410. AddArraySlot(b1.list, {    // 6
  411.     item: c14
  412. });
  413. AddArraySlot(b1.list, {    // 7
  414.     item: c16
  415. });
  416. AddArraySlot(b1.list, {    // 8
  417.     item: c18
  418. });
  419. AddArraySlot(b1.list, {    // 9
  420.     level: 2,
  421.     item: c19
  422. });
  423. AddArraySlot(b1.list, {    // 10
  424.     level: 2,
  425.     item: c22
  426. });
  427. AddArraySlot(book.browsers, b1);
  428.  
  429. // Indices and Sub-Indices
  430.